/*
 * @Author: 邵东亮 1762111402@qq.com
 * @Date: 2024-12-13 17:11:47
 * @LastEditors: 邵东亮 1762111402@qq.com
 * @LastEditTime: 2024-12-16 09:07:18
 * @Description:
 * @FilePath: \express\bigData_server\routes\user.js
 */
const express = require("express");
const router = express.Router();
const userController = require("../controller/userController");
const upload = require("../util/upload");

/**
 *@api {post} api/upload  上传文件
 *@apiHeader {String} Authorization token值，放在请求头中
 * @apiHeader {String} Content-Type=multipart/form-data  必须指定为表单数据格式
 *@apiDescription 上传文件功能说明
 *@apiName upload
 *@apiGroup user
 * @apiBody {File} file 上传的文件（通过form-data传递）
 *@apiSuccessExample {json} Success-Response:
 *{
 *    "msg": "文件上传成功",
 *    "status": 200,
 *    "data": null
 *}
 *@apiSampleRequest api/upload
 *@apiVersion 1.0.0
 */
//上传文件的路由
router.post("/upload", upload, userController.upload);
/**
 *@api {post} api/userList  获取用户列表
 *@apiHeader {String} Authorization token值，放在请求头中
 *@apiDescription 获取用户列表功能说明
 *@apiName userList
 *@apiGroup user
 *@apiSuccessExample {json} Success-Response:
 *{
 *	  "code": 200,
    "msg": "查询成功",
    "data": [{
            "username": "张三",
            "password": "123456",
            "email": "123456789@qq.com",
            "id": 1
        }]
 *}
 *@apiSampleRequest api/userList
 *@apiVersion 1.0.0
 */
// 获取用户列表的路由
router.get("/userList", userController.userList);

/**
 *@api {post} api/register   注册用户
  *@apiHeader {String} Authorization token值，放在请求头中
 *@apiDescription 注册用户功能说明
 *@apiName register
 *@apiGroup user
  *@apiBody  {String} username 用户名
 *@apiBody  {String} password 密码
 *@apiBody  {String} email 邮箱
 *@apiSuccessExample {json} Success-Response:
{
    "msg": "账号注册成功",
    "status": 200,
    "data": null
}
 *@apiSampleRequest api/register
 *@apiVersion 1.0.0
 */
// 注册用户的路由
router.post("/register", userController.register);

/**
 *@api {delete} api/delUsers/:id   删除用户
  *@apiHeader {String} Authorization token值，放在请求头中
 *@apiDescription 删除用户功能说明
 *@apiName delUsers
 *@apiGroup user
  *@apiParam {Number} id 用户id
 *@apiSuccessExample {json} Success-Response:
{
      msg: "删除成功",
      status: 200,
      data: null,
}
 *@apiSampleRequest api/delUsers/:id
 *@apiVersion 1.0.0
 */
// 删除用户的路由
router.delete("/delUsers/:id", userController.deleteUser);
module.exports = router;
